package edu.jit.nsi.iot_ms.serviceimpl.session;


import lombok.Data;
import org.apache.mina.core.session.IoSession;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
public class TermSession {
    private int termid;
    private int termtype;
    private String deveui;
    private IoSession iosession;
    private List<Integer> sensorparams; //传感器参数列表
    private List<Integer> equiplst;  //设备列表
    private List<PhySnrInfo> physnrlst;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date time;
    private Date intime;

    public TermSession(int tid, int type, IoSession iosess){
        termid = tid;
        termtype = type;
        iosession = iosess;
        sensorparams = new ArrayList<Integer>();
        equiplst = new ArrayList<Integer>();
        time = new Date();
        intime = new Date();
    }

    public TermSession(int tid, int type, String eui){
        termid = tid;
        termtype = type;
        deveui = eui;
        sensorparams = new ArrayList<Integer>();
        equiplst = new ArrayList<Integer>();
        time = new Date();
        intime = new Date();
        if(type==5){
            physnrlst = new ArrayList<>();
        }
    }

    public void addPhysnrlst(PhySnrInfo p) {
        physnrlst.add(p);
    }
}
